package cn.zqy.demo.day08;

/**
 * java.util.Math,提供了大量数学静态方法，4个常用
 * 1.double abs(数字)      ：绝对值
 * 2.double ceil(数字)     ：向上取整
 * 3.double floor(数字)    ：向下取整
 * 4.long round(数字)    ：四舍五入
 *
 * Math.PI：圆周率常量
 * */
public class Demo01Math {
    public static void main(String[] args) {
        /*1. 绝对值*/
        System.out.println(Math.abs(8.9));  //8.9
        System.out.println(Math.abs(-8.9)); //8.9
        System.out.println(Math.abs(0));    //0
        System.out.println("===================");

       /* 2.向上取整*/
        System.out.println(Math.ceil(9.9)); //10.0
        System.out.println(Math.ceil(9.1)); //10.0
        System.out.println(Math.ceil(9.0)); //9.0
        System.out.println("===================");

        /* 3.向下取整*/
        System.out.println(Math.floor(9.9));  //9.0
        System.out.println(Math.floor(9.1));  //9.0
        System.out.println(Math.floor(9.0));  //9.0
        System.out.println("===================");

        /* 4.四舍五入*/
        System.out.println(Math.round(9.5));  //10
        System.out.println(Math.round(9.4));  //9
        System.out.println("===================");

        System.out.println(Math.PI);
    }
}
